<?php


class My_View_Helper_Unit extends Zend_View_Helper_Abstract
{

    const  PERCENTAGE      = '%';
    const  KILOWATT      = 'kW';
    const  WATT          = 'W';
    const  SQUARE_METER  = 'm²';
    const  KILOWATT_HOUR = 'kWh';
    const  WATT_HOUR     = 'Wh';
    const  MONEY         = '€';
    const  WATT_RACK     = 'W/rack';
    const  WATT_SQUARE_METER  = 'W/m²';

    
    
    
    public function unit($type,$value=null,$precision=2)
    {
        if (isset($type) === false){
                throw new Zend_Measure_Exception("Type ($type) is unknown");
        }
        
        if(func_num_args()==1){ 
            return constant("self::$type");
        }elseif(is_numeric($value)){
            return $this->view->numES($value,$precision).' '. constant("self::$type");
        }else{
            return '';
        }
        
        
    }



}